import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['font.sans-serif']=[u'simHei']

def sigmoid(x):
    return 1/(1+np.exp(-x))


# 生成x值
x = np.linspace(-6,6,100)
y = sigmoid(x)

# 绘图
plt.figure(figsize=(8,6))
plt.plot(x,y,'b',label='Logistic函数')
plt.axhline(y=0.5,color='r',linestyle='--',label='y=0.5')
plt.axvline(x=0,color='g',linestyle='--',label='x=0')
plt.xlabel('x')
plt.ylabel('y')
plt.title('logistic 函数')
plt.legend()
plt.grid(True)
plt.show()
    